package com.cl.short_video_java.web.sys_setting;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cl.short_video_java.annotation.IsRole;
import com.cl.short_video_java.annotation.Log;
import com.cl.short_video_java.annotation.Login;
import com.cl.short_video_java.common.Const;
import com.cl.short_video_java.common.Result;
import com.cl.short_video_java.menum.BusinessType;
import com.cl.short_video_java.pojo.SysFastOper;
import com.cl.short_video_java.service.SysFastOperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author 付
 * @Date 2024-11-03 14:25
 * @Version 1.0
 * @description 快捷操作设置接口
 * @since 1.0
 */
@RestController
@RequestMapping("/setting/fast")
public class SysFasterOperController {

	private SysFastOperService sysFastOperService;

	@Autowired
	public SysFasterOperController(SysFastOperService sysFastOperService) {
		this.sysFastOperService = sysFastOperService;
	}

	/**
	 * 获取启用的快捷操作
	 *
	 * @return 查询数据
	 */
	@GetMapping("/list")
	@Login(issuer = Const.GRADE_ADMIN)
	@IsRole(menuId = 15)
	public Result getFasterList() {
		Map<String, List<SysFastOper>> list = sysFastOperService.getList();
		return Result.success(list);
	}

	@GetMapping("/fast")
	@Login(issuer = Const.GRADE_ADMIN)
	@IsRole(menuId = 15)
	public Result getFastList() {
		return Result.success(sysFastOperService.list(new QueryWrapper<SysFastOper>().eq("is_delete", 0)));
	}

	@Log(title = "快捷操作", businessType = BusinessType.UPDATE)
	@Login(issuer = Const.GRADE_ADMIN)
	@IsRole(menuId = 15)
	@GetMapping("/save")
	public Result save(Integer id, Integer type) {
		sysFastOperService.save(id, type);
		return Result.success();
	}
}
